home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / Shells / bsh.lzh / bsh / hex < prev    next >
Encoding:
Text File  |  1993-02-14  |  796 b   |  29 lines

  1. if !?argv[1]
  2.     label usage
  3.     echo usage: hex number
  4.     exit 10
  5. endif
  6. if !numeric(argv[1])
  7.     goto usage
  8. endif
  9. local number result
  10. if number=argv[1]
  11.     result=""
  12. else
  13.     result="0"
  14. endif
  15. while number
  16.     result=cat(substr('0123456789ABCDEF',(number&15)+1,1),"$result")
  17.     number=(number>>4)&0x0fffffff
  18. endwhile
  19. echo $result
  20. exit 0
  21. # Hex - convert a decimal number to an hex string.  Normally, strings
  22. # which contain only digits are considered to be numeric and are
  23. # therefore subject to loss of leading zeros; this is why result is
  24. # quoted in the loop.
  25. # Hex is presented as is; no warrantee is either expressed or implied
  26. # as to it's suitability to any purpose whatsoever.  You assume all the
  27. # risk for all damage, even if caused by a defect in the software, no
  28. # matter how awful.
  29.